<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>FIRST</title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			.container{
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		canvas{
			width: 400px;
			height: 400px;
			border: 10px solid #333333;
		}	
		
		</style>
	</head>
	<body>
		<div class="container">
		<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script>
		window.onload = function() {
			
			let oCanvas = document.getElementById('canvas');
		
			console.dir(oCanvas);
			
			let oPen=oCanvas.getContext("2d");
			
//			oPen.lineWidth = 10;
//			oPen.moveTo(100,100);
//			oPen.lineTo(300,300);
//			oPen.strokeStyle = "aqua";
//			oPen.stroke();
//			
//			oPen.beginPath()
//			oPen.moveTo(100,200);
//			oPen.lineTo(200,200);
//			oPen.strokeStyle = "red";
//			oPen.stroke();

//          oPen.arc(100,100,50,Math.PI/180*90,false);
//          oPen.closePath();
//          oPen.stroke();
//          
//          oPen.beginPath();
//          oPen.arc(200,200,50,Math.PI/180*90,false);
//          oPen.closePath();
//          oPen.stroke();

            //这个点的坐标如果这个点在路径中，就返回true，否则久返回false
            //isPointInPath(x,y)
            
            oPen.rect(50,50,80,80);
            oPen.stroke();
            oPen.fill();
            
            if(oPen.isPointInPath(60,60)){
            	alert('在路径中')
            }else {
            	alert('不在路径中')
            }
            
            oPen.lineWidth = 10;
			oPen.moveTo(100,100);
			oPen.lineTo(300,300);
			oPen.strokeStyle = "aqua";
			oPen.stroke();
			
			oPen.save();
			
			oPen.beginPath()
			oPen.moveTo(100,200);
			oPen.lineTo(200,200);
			oPen.strokeStyle = "red";
			oPen.stroke();
			
			oPen.restore();
			oPen.moveTo(100,300);
			oPen.lineTo(300,100);
			oPen.stroke();
            
		}	
	</script>
</html>
